package cn.strutsDemo.action;

import cn.strutsDemo.User;
import cn.strutsDemo.util.BaseAction;

public class UserAction {
    private User user;
    private String nextDispose;

    public String getNextDispose() {
        return nextDispose;
    }

    public void setNextDispose(String nextDispose) {
        this.nextDispose = nextDispose;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
    public String login(){
        if(user.getUserName().equals("admin")&&user.getPwd().equals("admin")){
            if(user.getIsManager()==0){
                this.setNextDispose("manager");
            }else if(user.getIsManager()==1){
                this.setNextDispose("common");
            }
            BaseAction.getSession().put("user",user);
            return "success";
        }else{
            return "error";
        }
    }
    public String register(){
        System.out.println("添加用户成功");
        return "success";
    }
}
